<?php

class Browse extends CI_Controller{

	function index(){

		$this->load->view('view_mindmap');
	}
	
	function allCategories(){
		//get all ideas
		$this->load->model('idea_model');
		
		$data['ideas'] = (array)$this->idea_model->getIdeaUnderCategory('all');
		
		$data['categoryName']= 'All Categories';
		
		$this->load->view('view_category', $data);		
	}

	function byCategory($catgName = NULL){
		//get idea by category
		if($catgName === NULL){
			//if category name is null	
			show_404(base_url());
		}
		
		$this->load->model('idea_model');
		
		//replace  _ with " "
		$catgName = str_replace("_", " ", $catgName);
		
		$data['ideas'] = (array)$this->idea_model->getIdeaByCategory($catgName);
		$data['categoryName']=$catgName;
		
		$this->load->view('view_category', $data);
	}

	function underCategory($parentCatgName = NULL){
		//get all ideas under specific parent category
		
		if($parentCatgName === NULL){
			//if parameter is null	
			show_404(base_url());
		}
		
		$this->load->model('idea_model');
		
		$data['ideas'] = (array)$this->idea_model->getIdeaUnderCategory($parentCatgName);
		$data['categoryName']= $parentCatgName;
		
		$this->load->view('view_category', $data);
	}
}

?>